/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gray.swing.element;

import java.awt.Container;
import java.math.BigDecimal;
import java.util.Date;
import javax.swing.JLabel;
import gray.Frame;
import tool.SimpleCal;
import java.awt.Color;

/**
 *
 * @author martin
 */
public class TextElem extends JLabel implements Frame{

    private TextElem(final String txt){
        super(txt);

    }
    
    public static Frame factoryTxt(final String txt){
        return new TextElem(txt);
    }
    
    public static Frame factoryMoney(final BigDecimal num){
        return new TextElem(String.format("%.2f$", num));
    }
    
    public static Frame factoryDate(final Date date){
        //return new TextElem(String.format("YYYY-MM-DD",date),theme);
      return new TextElem(SimpleCal.dateToSql(date));
    }
    
    public static Frame factoryTime(final Date hour){
        //return new TextElem(String.format("HH:mm:SS", hour),theme);
      return new TextElem(SimpleCal.timeToSql(hour));
    }
    
    public static Frame factoryPercentage(final BigDecimal num){
        return new TextElem(String.format("%2.1f/%", num));  
    }
    
    public static Frame factoryString(final String num){
        return new TextElem(String.format("%d", num));  
    }
    
    @Override
    public Container container() {
        return this;
    }

    @Override
    public Boolean ready() {
        return true;
    }
    
}
